import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'logic.dart';
import 'package:scan/scan.dart';

class ScanPage extends StatelessWidget {
  final logic = Get.put(ScanLogic());

  final ScanController controller = ScanController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Scaffold(
          body: SafeArea(
            top: true,
            bottom: true,
            child: Stack(
              children: [
                ScanView(
                  controller: controller,
                  scanAreaScale: .7,
                  scanLineColor: Colors.green,
                  onCapture: (result) {
                    Get.back(result: result);
                  },
                ),
                Positioned(
                  bottom: 0,
                  child: Row(
                    children: [
                      ElevatedButton(
                        child: const Text("toggleTorchMode"),
                        onPressed: () {
                          controller.toggleTorchMode();
                        },
                      ),
                      ElevatedButton(
                        child: const Text("pause"),
                        onPressed: () {
                          controller.pause();
                        },
                      ),
                      ElevatedButton(
                        child: const Text("resume"),
                        onPressed: () {
                          controller.resume();
                        },
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        )
    );
  }
}